<template>
  <div class="demo-basic-vueStudyChild-attrDemo">
    <section>
      <h3>all ([promise1, promise2, ...])</h3>
      <p><b>promise1, promise2, ...</b>: 多个promise并发执行</p>
      <h3>spread(function (arg1, arg2, ...) {})</h3>
      <p><b>arg1, arg2, ...</b>: promises的执行结果与参数一一对应</p>
    </section>
    <pre>
      <code class="javascript">
      import getData from '...'

      getData.<b>all</b>([promise1, promise2])
        .then(getData.spread(function (res1, res2) {
          ...
        })
      </code>
    </pre>
    <section>
      <h3>allPromise (promise1, promise2, ...)</h3>
      <p><b>promise1, promise2, ...</b>: 多个promise并发执行</p>
      <pre>
        <code>
        import getData from '...'

        getData.<b>all</b>(promise1, promise2)
          .then(getData.spread(function (response) {
            response[0] // 第一个promise的结果
            response[1] // 第二个promise的结果
          })
        </code>
      </pre>
    </section>

  </div>
</template>

<script>
  import hljs from 'highlight.js'
  export default {
    // 组件被挂载的时候执行的方法
    mounted: function () {
      window.setTimeout(function () {
        $('.demo-basic-vueStudyChild-attrDemo pre code').each(function(i, block) {
          hljs.highlightBlock(block);
        });
      }, 200);
    }
  }
</script>
